package leetcode.offer;

import leetcode.base.TreeNode;

/**
 * ClassName: SymmetricTree
 * Description: leetcode-剑指offer 28.对称的二叉树
 * date: 2021-11-03 10:05
 *
 * @author liyifan
 */
public class SymmetricTree {
    public boolean isSymmetric(TreeNode root) {
        return root == null ? true : recur(root.left, root.right);
    }

    public boolean recur(TreeNode l, TreeNode r){
        if (l == null && r == null) {
            return true;
        }
        if (l == null || r == null || l.val != r.val)
            return false;
        return recur(l.left, r.right) && recur(l.right, r.left);
    }
}
